<template>
	<view>


		<view class="list">
			<view class="block" style="width: 350upx;">日期</view>
			<view class="block" style="width: 200upx;">金额</view>
			<view class="block" style="width: 100upx;">状态</view>
			<view class="block" style="width: 100upx;">操作</view>
		</view>
		<view class="hr"></view>


		<view v-for="(item, index) in data" :key="index">

			<view class="list">
				<view class="block" style="width: 350upx;">{{item.FetTime}}</view>
				<view class="block" style="width: 200upx;">{{item.FetAmount}}</view>
				<view class="block" style="width: 100upx;">{{item.FetStatus}}</view>
				<view class="block" style="color: #E93B3D; width: 100upx;" @click="navToDetailPage(item)">查看</view>
			</view>
			<view class="hr"></view>

		</view>

<view style="margin-top: 50upx;">
		<uni-pagination :total="total" :current="current" :pageSize="pageSize" @change="test"></uni-pagination>
</view>

	</view>
</template>

<script>
	import uniPagination from "@/components/uni-pagination/uni-pagination.vue"
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				total: 0,
				pageSize: 20,
				current: 1,
				data: []
			}
		},
		computed: {
			...mapState(['token', 'exp_time', 'hasLogin', 'userInfo'])
		},
		onShow() {
			this.test()
		},
		components: {
			uniPagination
		},
		methods: {

			test(item) {



				if (item != undefined) {

					if (item.type == 'next') {
						this.current += 1

					}

					if (item.type == 'prev') {
						this.current -= 1
					}

				}




				uni.request({
					url: this.$serverUrl + '/app/balance/fetch/' + this.userInfo.MemId,
					header: {
						"Content-Type": "application/json",
						"Authorization": this.token
					},
					data: {
						"page_index": this.current,
						"page_size": this.pageSize
					},
					method: "POST",
					success: (e) => {
						if (e.data.success) {
							this.total = e.data.total
							this.data = e.data.rows

						}
					},
					fail: (e) => {
						console.log(e.errMsg)
					}
				})



			},
			navToDetailPage(item) {
				//测试数据没有写id，用title代替
				uni.navigateTo({
					url: `/pages/bill/billinfo?item=${JSON.stringify(item)}`
				})
			},




		}
	}
</script>

<style>
	.block {


		text-align: center;
		font-size: 30upx;
		margin-top: 30upx;
		margin-bottom: 30upx;

	}

	.hr {

		height: 1px;
		background: #dbdbdb;
		transform: scaleY(0.5);

	}


	.list {
		display: flex;
		flex-direction: row;
	}
</style>
